package com.yijiu.trb;

import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class App extends Application
{
	public static App instance = null;
	
	private Toast toast;
	
	private View toastView;
	
	// public static final String IMAGE_URL = "http://www.tzydb.com";
	
	// public static final String IMAGE_URL = "http://www.tzydb.com:8081";
	
	public static final String IMAGE_URL = "http://www.tzydb.com:8082";
	
	@Override
	public void onCreate()
	{
		super.onCreate();
		instance = this;
	}
	
	@Override
	public void onTerminate()
	{
		super.onTerminate();
	}
	
	public void showMsg(String msg, Context context)
	{
		if (TextUtils.isEmpty(msg))
		{
			return;
		}
		if (null == toast)
		{
			toast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
		}
		if (null == toastView)
		{
			toastView = View.inflate(context, R.layout.view_toast, null);
		}
		((TextView) toastView).setText(msg);
		toast.setGravity(Gravity.CENTER, toast.getXOffset() / 2, toast.getYOffset() / 2);
		toast.setView(toastView);
		toast.show();
	}
	
	public void showMsg(String msg)
	{
		if (TextUtils.isEmpty(msg))
		{
			return;
		}
		if (null == toast)
		{
			toast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
		}
		if (null == toastView)
		{
			toastView = View.inflate(this, R.layout.view_toast, null);
		}
		((TextView) toastView).setText(msg);
		toast.setGravity(Gravity.CENTER, toast.getXOffset() / 2, toast.getYOffset() / 2);
		toast.setView(toastView);
		toast.show();
	}
}
